package main

import "fmt"

//声明全局变量
var g int = 20
//var a int = 20

// 函数定义，两数相加
func sum(a, b int) int {
	fmt.Printf("sum()函数中a = %d\n", a)
	fmt.Printf("sum()函数中b = %d\n", b)
	return  a + b
}

func main() {
	/*//声明局部变量
	var a, b, c int
	//初始化参数
	a = 10
	b = 20
	c = a + b
	fmt.Printf("结果：a = %d, b = %d, c = %d\n", a, b, c)*/

	/*var a, b int
	a = 10
	b = 20
	g = a + b
	fmt.Printf("结果：a = %d, b = %d, g = %d\n", a, b, g)*/

	/*//声明局部变量
	var g int = 20//局部变量可以和全局变量重名，但会优先考虑局部变量
	fmt.Printf("结果：g = %d\n", g)*/

	var a int = 10
	var b int = 20
	var c int = 0
	fmt.Printf("main()函数中a = %d\n", a)
	c = sum(a, b)
	fmt.Printf("main()函数中c = %d\n", c)




}
